package com.hackerrank.challenges.servicelane;

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), T = in.nextInt(), w[] = new int[N];
		for(int n = 0; n < N; n++)
			w[n] = in.nextInt();
		for(int t = 0; t < T; t++) {
			int i = in.nextInt(), j = in.nextInt(), l = Integer.MAX_VALUE;
			for(int k = i; k <= j; k++)
				l = Math.min(l, w[k]);
			System.out.println(l);
		}
	}
}
